package ch.zhaw.cctd.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.JPanel;

/**
 * Die kleinen Kästchen in der Lobby, welche anzeigen, ob ein Spieler bereit ist oder nicht.
 * 
 * @author nathanaelkoch
 *
 */
public class ReadynessIndicator extends JPanel {
	
	private static final long serialVersionUID = 1L;
	private Color rectColor;
	private boolean ready;

	public ReadynessIndicator() {
		super();
		this.setReady(false);
		this.setPreferredSize(new Dimension(15,15));
		this.setVisible(false);
	}
	
	public ReadynessIndicator(boolean ready) {
		super();
		this.setReady(ready);
		this.setPreferredSize(new Dimension(15,15));
	}
	
	public void setReady(boolean ready) {
		this.ready = ready;
		if(this.ready) {
			rectColor = new Color(0,200,0);
		} else {
			rectColor = Color.red;
		}
		this.repaint();
	}
	
	public void paint(Graphics g) {
		g.setColor(rectColor);
		g.fillRect(0, 0, getWidth(), getHeight());
	}
	
}
